﻿<cfsilent>
	<cfscript>
		
		propAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "学位课管理 - 学位课资格审核");
		
		/* 当前毕业生判断 grade + schooling_length = ? */
		gradeLeast = year( now() );
		
		/* 拥有毕业生的学院和专业列表 */
		sql = "SELECT 
				a.institute_id, 
				a.institute_name, 
				a.institute_pyidx, 
				b.sbj_id, 
				b.sbj_name, 
				c.grade, 
				count(*)  grad_sum 
				FROM t_institute a 
				INNER JOIN t_subject b ON a.institute_id = b.institute_id 
				INNER JOIN t_class c ON c.sbj_id = b.sbj_id 
				INNER JOIN t_student d ON d.cls_id = c.cls_id 
				INNER JOIN t_grad_review e ON e.stu_id = d.stu_id 
				WHERE 
					c.grade + b.schooling_length = :gradeLeast 
					AND 
					c.cls_scale > 0 
					AND 
					e.is_passed = '1' 
				GROUP BY 
					a.institute_id, a.institute_name, a.institute_pyidx, b.sbj_id, b.sbj_name, c.grade  
				ORDER BY 
					a.institute_name, b.sbj_name ";
		
		queryObj = new Query( datasource=application.dnsSlave );
		queryObj.addParam( name="gradeLeast", value=gradeLeast, cfsqltype="cf_sql_integer" );

		rs_subject = queryObj.execute( sql=sql ).getResult();
		
		
		/* 生成学院列表 */
		sql = "SELECT  
					institute_id, institute_name, 
					SUM(grad_sum) grad_sum, 
					COUNT(*) sbj_sum 
					FROM query 
					GROUP BY institute_id, institute_name 
					ORDER BY institute_pyidx";
		
		queryObj = new Query( dbtype="query" );
		queryObj.setAttributes( query=rs_subject );

		rs_institute = queryObj.execute( sql=sql ).getResult();
		
		
		/* 搜索毕业生 */
		keyword = event.getArg("Keywords");
		
		rs_student = queryNew("stu_id, stu_name, cls_name, student_prop");
		
		if ( len(keyword) ) {
			
			sql = "SELECT 
						 a.stu_id, a.stu_name, 
						 b.cls_name, b.sbj_id, b.grade, 
						 d.student_prop 
					FROM 
						 t_student a 
						 INNER JOIN t_class b ON b.cls_id = a.cls_id 
						 INNER JOIN t_subject c ON c.sbj_id = b.sbj_id 
						 INNER JOIN t_student_status d ON d.stu_id = a.stu_id 
						 INNER JOIN t_degree_review e ON e.stu_id = a.stu_id 
					WHERE 
						 b.grade + c.schooling_length = :gradeLeast 
						 AND (
						 	a.stu_id LIKE :condition 
						 	OR 
						 	a.stu_name LIKE :condition 
							) 
					ORDER BY 
						 a.stu_name ";
					
			queryObj = new Query( datasource=application.dnsSlave, maxRows=60 ) ;
			queryObj.addParam( name="condition", value=keyword&"%" , cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="gradeLeast", value=gradeLeast, cfsqltype="cf_sql_integer" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
			
			
		}


		currentTab = event.getArg("TabID", "labDepartment");
		
		
		passArgs = structNew();
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('gradReview')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">毕业生资格审核</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>学位资格审核
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labDepartment">class="active"</cfif> id="labDepartment" tabTarget="Department">毕业生学院</span>
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索毕业生</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Department" class="tabContent">
					
					<cfloop query="rs_institute">
					
						<div class="noticeBlock">
							<h3><cfoutput>#rs_institute.institute_name#</cfoutput></h3>
							<p><span class="img icon16x16 message"></span>该学院已毕业的为 <em><cfoutput>#rs_institute.grad_sum#</cfoutput></em> 人, 分布于 <em><cfoutput>#rs_institute.sbj_sum#</cfoutput></em> 个专业</p>
							<hr/>
						</div>
						
						<!--- 读取学院下的毕业生专业分布 --->
						<cfscript>
							
							depId = rs_institute.institute_id;
							
							sql = "SELECT sbj_id, sbj_name, grad_sum, grade FROM query WHERE institute_id = :depId ORDER BY sbj_id ";
		
							queryObj = new Query( dbtype="query" );
							queryObj.setAttributes( query=rs_subject );
							queryObj.addParam( name="depId", value=depId, cfsqltype="cf_sql_varchar" );

							rs_dep_subject = queryObj.execute( sql=sql ).getResult();
							
						</cfscript>
						
						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_dep_subject">
									<cfset structInsert( passArgs, "SBJ", rs_dep_subject.sbj_id, true ) />
									<cfset structInsert( passArgs, "GRD", rs_dep_subject.grade, true ) />
									<dl>
										<dt>
											<a href="<cfoutput>#buildURL('gradDegreeBySubject', passArgs)#</cfoutput>">
												<em class="subject"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_dep_subject.sbj_name#</cfoutput></h3>
													<div><cfoutput>#rs_dep_subject.grade#</cfoutput> 级已经毕业学生为 <cfoutput>#rs_dep_subject.grad_sum#</cfoutput> 人</div>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>
								<!--- 移除额外参数 --->
								<cfset structDelete( passArgs, "SBJ" ) />
								<cfset structDelete( passArgs, "GRD" ) />
							</div>
						</div>
						
					</cfloop>
					
				</div>
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('gradDegreeReview')#</cfoutput>">
						<input type="hidden" name="TabID" value="labSearch" />
						
						<div class="label">
							<b>学号或姓名</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
					<cfif rs_student.recordCount>

						<div class="clearfix">
							<div class="UICardTable">
                                <cfloop query="rs_student" >
									
									<cfset structInsert( passArgs, "STU", rs_student.stu_id, true ) />
									<cfset propAdvice.parseProperty( rs_student.student_prop ) />
									
									<dl <cfif not propAdvice.getInSchool()>class="disabled"</cfif>>
										<dt>
											<a href="<cfoutput>#buildURL('gradDegreeProfileView', passArgs)#</cfoutput>">
												<em class="people"><!--imgholder--></em>
												<dd>
													<h3><cfoutput>#rs_student.stu_name#</cfoutput> - <cfoutput>#rs_student.cls_name#</cfoutput></h3>
													<p><cfoutput>#rs_student.stu_id#</cfoutput></p>
												</dd>
											</a>
										</dt>
									</dl>
								</cfloop>
								<!--- 移除额外参数 --->
								<cfset structDelete( passArgs, "STU" ) />
								<cfset structDelete( passArgs, "SBJ" ) />
								<cfset structDelete( passArgs, "GRD" ) />					
							</div>
						</div>
					
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>